<%@page import="com.scrum.Object.User"%>
<%@page import="java.io.File"%>
<%@page import="com.scrum.Object.Post"%>
<%@page import="java.util.Vector"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="../css/bootstrap-theme.min.css" rel="stylesheet"
	type="text/css" />
<link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="../css/post_style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/ckeditor.js"></script>

<style>
.boder-from {
	border: 1px solid #FFFF;
}
</style>
</head>
<body>
	<div class="navbar">
		<!-- Wrap the .navbar in .container to center it within the absolutely positioned parent. -->
		<!-- <div class="container"> -->

		<!-- <a class="brand" href="#"><img src="assets/img/logo.png" width='80px' height='75px'></a> -->
		<div class="navbar navbar-default">
			<div class="navbar-inner-top">
				<div class="container">
					<!-- Responsive Navbar Part 1: Button for triggering responsive navbar (not covered in tutorial). Include responsive CSS to utilize. -->
					<button type="button" class="btn btn-navbar" data-toggle="collapse"
						data-target=".nav-collapse">
						<span class="icon-bar"></span> <span class="icon-bar"></span> <span
							class="icon-bar"></span>
					</button>
					<!-- Responsive Navbar Part 2: Place all navbar contents you want collapsed withing .navbar-collapse.collapse. -->
					<a class="brand" href="#"></a>
					<div class="nav-collapse collapse">
						<ul class="nav">
							<!-- <li class="active"><a href="#">Home</a></li> -->
							<!-- Read about Bootstrap dropdowns at http://twbs.github.com/bootstrap/javascript.html#dropdowns -->
					</div>
					<!--/.nav-collapse -->
				</div>
			</div>
			<!-- /.navbar-inner -->
		</div>
		<!-- /.navbar -->

		<!-- </div> /.container -->
		<div class="navbar navbar-inverse">
			<div class="navbar-inner">
				<div class="container">
					<div class="nav-collapse collapse">
						<ul class="nav">
							<li><a href="#restaurants">Manager user</a></li>
							<li class="current"><a href="#recipes">Manager post</a></li>
							<li><a href="#about">Back home</a></li>
						</ul>
						<p class="navbar-form navbar-right right">
							<label class="active">Admin </label> <a href="#">Trân Thanh
								Tâm</a>, <a href="#">Login </a>
						</p>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- /.navbar-wrapper -->
	<div class="container">
		<div class="content">
			<h3
				style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif; color: #0088cc;">Manager
				post</h3>
			<hr>
			<form id="search" method="get" action="">
				 <input type="text" class="form-control style-search" name="search"/>
				 <button type="submit" class="btn btn-primary">Search</button>
				</form>
			<table
				class="table table-striped table-bordered table-hover table-condensed">
				<thead>
					<tr>
						<th>Index</th>
						<th>Title</th>
						<th>Image</th>
						<th>Owner</th>
						<th>Done</th>

					</tr>
				</thead>

				<%
			 	String search = request.getParameter("search");
				Vector<Post> post_list;
				Post post = null;
				String filePath;
				if (search == null){
					post_list = Post.getAllPost();
				}else{
					post_list = Post.getUserByTitle(search);
				}
				%>
				<tbody>
					<%
						for (int i = 0; i < post_list.size(); i++) {
							post = post_list.get(i);
							filePath = "../post/image/" + post.getImage();
							String username = User.getUserById(post.getUser_id())
									.getUsername();
					%>
					<tr class="warning">
						<td width="5px"><%=i + 1%></td>
						<td width="40px"><%=post.getTitle()%></td>
						<td width="40px"><img alt="" src="<%=filePath%>" height="150"
							width="150" /></td>
						<td width="40px"><%=username%></td>
						<td width="20px">
							<a type="button" role="button" class="btn btn-primary" href="viewpost.jsp?postid=<%=post.getId()%>">View</a>
							<a type="button" role="button" class="btn btn-danger" href="deletepost?postid=<%=post.getId()%>">Delete</a>
						</td>
					</tr>
					<%
						}
					%>
				</tbody>
			</table>
		</div>
	</div>

</body>
</html>